﻿<%@ Page Title="" Language="C#" EnableEventValidation="false" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="frmReserva.aspx.cs" Inherits="WebCinesItech.frmReserva" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
<script src="http://code.jquery.com/jquery-1.7.js" type="text/javascript"></script>
    <script src="Scripts/jquery-1.4.4.min.js" type="text/javascript"></script>
    <style type="text/css">
        .style1
        {
            width: 100%;
        }
        .style2
        {
            width: 164px;
        }
        .style3
        {
            width: 619px;
        }
        .style4
        {
        }
        .style5
        {
            width: 132px;
        }
    </style>
    <script type="text/javascript">

        $(document).ready(function () {

            var ddlpeli = $("#<%=ddlPelicula.ClientID%>");
            ddlpeli.append($('<option></option>').val('0').html('::Seleccione Pelicula::'));
            var ddlHora = $("#<%=ddlHorario.ClientID%>");
            ddlHora.append($('<option></option>').val('0').html('::Seleccione Horario::'));
            //jQuery.support.cors = true;
            $.ajax({
                type: "GET",
                url: "http://localhost:49911/Cines.svc/Cines",
                data: "{}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                processdata: true,
                success: function (data) {
                    //alert("bien");
                    var i = 0;
                    var ddl = $("#<%=ddlCine.ClientID%>");
                    ddl.append($('<option></option>').val('0').html('::Seleccione Cine::'));
                    $.each(data, function () {
                        //$("#Select1").append($("<option></option>").attr("value", data[i].Codcine).text(data[i].Nombre));
                        //ddl.append($('<option></option>').val(data[i].Codcine).html(data[i].Nombre));
                        ddl.append($("<option></option>").attr("value", data[i].Codcine).text(data[i].Nombre));
                        i++;
                    });
                },
                error: function (err) {
                    alert("Errorr");
                }
            });


            $("#<%=ddlCine.ClientID%>").change(function () {
                cine = $("#<%=ddlCine.ClientID%>").val();
                //alert(moneda);
                $("#<%=hdCine.ClientID%>").val(cine);
                $.ajax({
                    type: "GET",
                    url: "http://localhost:49911/Peliculas.svc/Pelicula/" + cine,
                    data: "{}",
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    processdata: true,
                    success: function (data) {
                        //alert("bien");
                        $("select[id$=ddlPelicula] > option").remove();
                        var i = 0;
                        var ddl = $("#<%=ddlPelicula.ClientID%>");
                        ddl.append($('<option></option>').val('0').html('::Seleccione Pelicula::'));
                        $.each(data, function () {
                            ddl.append($("<option></option>").attr("value", data[i].PeliculaID).text(data[i].Titulo));
                            i++;
                        });

                    },
                    error: function (err) {
                        alert("Errorr");
                    }
                });

            });


            $("#<%=ddlPelicula.ClientID%>").change(function () {
                cine = $("#<%=ddlCine.ClientID%>").val();
                pelicula = $("#<%=ddlPelicula.ClientID%>").val();
                $("#<%=hdPelicula.ClientID%>").val(pelicula);
                //alert(moneda);
                $.ajax({
                    type: "GET",
                    url: "http://localhost:49911/Horarios.svc/Horario/" + cine + "/" + pelicula,
                    data: "{}",
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    processdata: true,
                    success: function (data) {
                        //alert("bien");
                        $("select[id$=ddlHorario] > option").remove();
                        var i = 0;
                        var ddl = $("#<%=ddlHorario.ClientID%>");
                        ddl.append($('<option></option>').val('0').html('::Seleccione Horario::'));
                        $.each(data, function () {
                            ddl.append($("<option></option>").attr("value", data[i].CodHorario).text(data[i].DescripHorario));
                            i++;
                        });

                    },
                    error: function (err) {
                        alert("Errorr");
                    }
                });

            });
            $("#<%=ddlHorario.ClientID%>").change(function () {
                horario = $("#<%=ddlHorario.ClientID%>").val();
                $("#<%=hdHora.ClientID%>").val(horario);
            });

        });

</script>

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <table class="style1">
        <tr>
            <td class="style2">
                &nbsp;</td>
            <td class="style3">
                <table class="style1">
                    <tr>
                        <td colspan="4" align="center">
                            RESERVAR DE ASIENTOS DE SALA</td>
                    </tr>
                    <tr>
                        <td class="style5">
                            &nbsp;</td>
                        <td class="style4">
                            &nbsp;</td>
                        <td class="style2">
                            &nbsp;</td>
                        <td>
                            &nbsp;</td>
                    </tr>
                    <tr>
                        <td class="style5">
                            CINE</td>
                        <td class="style4">
                            <asp:DropDownList ID="ddlCine" runat="server" Width="150px">
                            </asp:DropDownList>
                        </td>
                        <td class="style2">
                            HORARIO DISPONIBLE</td>
                        <td>
                            <asp:DropDownList ID="ddlHorario" runat="server" Width="150px">
                            </asp:DropDownList>
                        </td>
                    </tr>
                    <tr>
                        <td class="style5">
                            PELICULA</td>
                        <td class="style4">
                            <asp:DropDownList ID="ddlPelicula" runat="server" Width="150px">
                            </asp:DropDownList>
                        </td>
                        <td class="style2">
                            NRO DE ASIENTOS</td>
                        <td>
                            <asp:TextBox ID="txtcnt" runat="server" MaxLength="1" Width="50px"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td class="style5">
                            &nbsp;</td>
                        <td class="style4" align="center" colspan="2">
                            <asp:Label ID="lblsumary" runat="server" Text="Label"></asp:Label></td>
                        <td>
                            &nbsp;</td>
                    </tr>
                    <tr>
                        <td class="style5">
                            &nbsp;</td>
                        <td class="style4" align="center" colspan="2">
                            <asp:Button ID="Button1" runat="server" Text="Enviar" onclick="Button1_Click" />
                        </td>
                        <td>
                            &nbsp;</td>
                    </tr>
                    <tr>
                        <td class="style5">
                            &nbsp;</td>
                        <td class="style4" align="center" colspan="2">
                            <asp:Label ID="lblmensaje" runat="server" Text="Label"></asp:Label>
                        </td>
                        <td>
                             <asp:HiddenField ID="hdCine" runat="server" /> 
            <asp:HiddenField ID="hdPelicula" runat="server" />
            <asp:HiddenField ID="hdHora" runat="server" /></td>
                    </tr>
                </table>
            </td>
            <td>
                &nbsp;</td>
        </tr>
    </table>

</asp:Content>
